﻿<%--<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetTrackingData.aspx.cs" Inherits="NLUNZ.GetTrackingData" %>--%>

<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
--%>


<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>    

<script language="c#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write("Pass!");
        string code = Request.QueryString["code"];
        string trackingNumber = Request.QueryString["trackingNumber"];
        Response.ContentEncoding = UTF8Encoding.UTF8;
        Response.Write(FindTracking(code, trackingNumber));
    }
            public string FindTracking(string code, string trackingNumber)
        {
            string webServiceUrl = @"http://api.kuaidi100.com/api?id={0}&com={1}&nu={2}&show=0&muti=1&order=asc";
            string apiKey = "fc8c15ca124131c7";
            string url = string.Format(webServiceUrl, apiKey, code, trackingNumber);

            WebResponse response;
            try
            {
                WebRequest request = WebRequest.Create(url);
                response = request.GetResponse();
            }
            catch (Exception ex)
            {
                return ex.Message + ex.StackTrace;
            }
            Stream stream = response.GetResponseStream();

            StreamReader reader = new StreamReader(stream);
            //string json = reader.ReadToEnd();
            return reader.ReadToEnd();
        }
</script>
